home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / Documentation / Development Notes / ODF Shared Library < prev    next >
Encoding:
Text File  |  1996-12-13  |  11.3 KB  |  251 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                      
  5. ODF Shared Library 
  6. ODF Release 3                                                                                                                                                             
  7.  
  8. This document provides information about the ODF shared library.
  9.  
  10.  
  11. Table of Contents
  12. -------------------------
  13. • Shipping ODFLibrary
  14. • Release-to-Release Binary Compatibility
  15. • SOM vs. Extern "C" Interfaces
  16. • Public vs Private APIs
  17. • C++ Wrapper Classes
  18. • Smart Pointers
  19. • Publicly Exported Functions (by Subsystem)
  20.  
  21.  
  22. All parts you build with ODF Release 3 require the ODF shared library ODFLibrary 1.2 or later.  ODFLibrary contains code from the Foundation and OS layers of ODF that is shared by all ODF parts.  The design choice to package part of ODF as a shared library has ramifications that you should be aware of when you develop ODF parts.  Those ramifications are covered here.
  23.  
  24.  
  25.  
  26. Shipping ODFLibrary
  27.  
  28. When you build ODF part editors with ODF Release 3, you must link against ODFLibrary 1.2.  When you ship your part editors, you must provide an installer.  Your installer should install the ODFLibrary along with your part editors into the 'Editors' folder. If an ODFLibrary is already present on your system, check the version number. Do not install an older version over a more recent one.  The ODFLibrary will maintain release to release binary compatibility so that older part editors will still work with the most recent version of the library.
  29.  
  30.  
  31.  
  32. Release-to-Release Binary Compatibility
  33.  
  34. When you ship a part built with ODF Release 3, your part editor (for example, WhizzyPart 1.0) and ODFLibrary 1.2 are installed into the user's Editors folder.  Meanwhile, we're busy developing ODF Release 4.  ODF R4 may have an improved ODFLibrary, say version 1.3. Along the way, we may have discovered and fixed bugs in ODFLibrary and released updates on the net, say versions 1.2.1 and 1.2.2.  Any of these versions could be installed into the Editors folder of  your users of WhizzyPart 1.0.   This means that we (the ODF team) must ensure backwards compatibility of ODFLibrary, or we'll break all ODF parts built against prior versions of ODFLibrary.
  35.  
  36. Fortunately, the Code Fragment Manager (CFM) and the CFM Runtime make this relatively easy.  We are not allowed to modify any of the exported APIs, but we can add new APIs, fix bugs, and even completely replace implementations beneath the APIs, and still be backwards compatible.
  37.  
  38. Note that classes and APIs defined in the ODF static libraries (i.e. not part of ODFLibrary) can be modified in future releases of ODF.  This means that when we ship ODF Release 4 (and later) that you may need to modify your source code and rebuild your part editor in order to take advantage of new features and improvements in the architecture.
  39.  
  40.  
  41.  
  42. SOM vs. Extern "C" Interfaces
  43.  
  44. The code in the ODF library is the implementation for much of the Foundation and OS layers of ODF.  The classes in these subsystems were originally designed as C++ classes, but in order to move the code into a shared library it was necessary to rearchitect the code.  Two choices were available to us: 1) convert the classes to SOM, and 2) convert to procedural APIs using C-style structs and functions (extern "C").  We ended up using both mechanisms.  ODFLibrary 1.2 has 21 SOM classes and around 500 extern "C" functions.
  45.  
  46.  
  47.  
  48. Public vs Private APIs
  49.  
  50. If you examine the list of exported functions from ODFLibrary you will see that most of them are named FW_PrivXXX.  Functions in ODF which begin with the "Priv" prefix are considered private, or internal, to ODF.  These functions are used internally by ODF and should never need to be called by your part editor.  In general, Priv functions are low-level (private) interfaces which are used by the implementation of higher-level (public) interfaces.  This is definitely the case for the Priv functions in ODF Library. For example, ODFLibrary exports 42 private functions that begin with the prefix "FW_PrivString_".  These functions are all implementations for the methods of the public class FW_CString.  FW_CString is a normal C++ class, and is statically linked into every ODF part.  However, every method of FW_CString is implemented as a single call to one of the FW_PrivString functions in ODFLibrary, so only a small amount of code is statically linked into your part. 
  51.  
  52.  
  53.  
  54. C++ Wrapper Classes
  55.  
  56. FW_CString is an example of a wrapper class.  Wrapper classes are thin wrappers around some other implementation.  ODF uses wrapper classes for much of the functionality implemented in ODFLibrary.  These wrapper classes are part of the public interface of ODF and are fully documented.  It is interesting to note that wrapper classes allowed us to minimize the impact of moving to a shared library architecture.  In ODF R3 there are wrapper classes whose interfaces are nearly identical to the full-fledged C++ classes from ODF 1.0d11.
  57.  
  58. Wrapper classes are not just used for wrapping the procedural C functions in ODFLibrary.  ODF provides some wrapper classes that wrap SOM classes from the ODF library as well.  For example,  FW_OFile is a SOM class defined in ODFLibrary.  In previous (pre-)releases of ODF, files were implemented using the FW_CFile class.  FW_CFile was designed to be used as a stack-based object.  Creating a FW_CFile  object opened the file, and destroying the FW_CFile object closed the file.  By placing the object on the stack, it was possible to guarantee that the file would be closed when the object went out of scope, even if an exception was thrown. SOM classes, however, cannot be created on the stack.  We did not want to give up the exception safety we get from creating FW_CFile objects on the stack, so we created a C++ class, FW_PFile,  to wrap the FW_OFile class.
  59.  
  60.  
  61.  
  62. Smart Pointers
  63.  
  64. FW_PFile is a C++ class that wraps the SOM class FW_OFile.  FW_PFile and FW_OFile together provide an interface and functionality almost identical to the old class FW_CFile.  Developers who used pre-release versions of ODF and had references to FW_CFile objects can very likely just search for FW_CFile and replace it with FW_PFile and their code will work (assuming other similar renamings are performed, and some . operators are changed to -> operators). So why didn't we leave FW_CFile named as it was? FW_PFile uses the P prefix instead of the C prefix because it is a smart pointer.  A smart pointer is an instance of class that overrides the member-selection operator (->) so that it can act as a pointer to some other representation object.  FW_PFile is a class that has a data member which is a pointer to a FW_OFile representation object, and overrides the operator-> method to allow access to the FW_OFile object.  Given an instance of FW_PFile, you can directly call any of the public member functions of FW_OFile.  Note that by simply defining the operator-> method, the class effectively inherits all of the public protocol of the representation class.  However, this protocol doesn't appear in the class declaration for the smart pointer.  We use the P prefix so that you'll remember that you can use the protocol of the representation class.
  65.  
  66.  
  67.  
  68. Publicly Exported Functions (by Subsystem)
  69.  
  70. There are 21 SOM classes and 97 public procedures exported by the ODFLibrary.  The following summarizes, by subsystem, the public APIs from ODFLibrary for each subsystem.  Note that some subsystems have no public APIs exported by ODFLibrary.  In all such cases, there will be public APIs defined by classes in one of the ODF static libraries that are linked into your part.  See the ODF Class Reference or Engineering Notes for more information.
  71.  
  72. NOTE: We chose to use SOM to make the 21 SOM classes so that it would be possible to create subclasses. However, it is not required that you subclass any of the SOM classes below, and most ODF part developers will have no need to do so.  Furthermore, there exist public C++ wrappers for most of the SOM classes.
  73.  
  74. Foundation::FWCommon
  75.  
  76. This subsystem defines the following public functions:
  77. FW_PrimitiveSetMemory
  78. FW_PrimitiveCopyMemory
  79. FW_PrimitiveFreeBlock
  80. FW_PrimitiveGetBlockSize
  81. FW_PrimitiveResizeBlock
  82. FW_PrimitiveAllocateBlock
  83. FW_PrimitiveCharacterIsSpace
  84. FW_PrimitiveCharacterToLower
  85. FW_PrimitiveCharacterToUpper
  86. FW_PrimitiveStringFindCharacter
  87. FW_PrimitiveStringCatenate
  88. FW_PrimitiveStringCopy
  89. FW_PrimitiveStringDuplicate
  90. FW_PrimitiveStringCompare
  91. FW_PrimitiveStringEqual
  92. FW_PrimitiveStringLength
  93.  
  94. Foundation::FWCollect
  95.  
  96. All exported functions are private.
  97.  
  98. Foundation::FWDebug
  99.  
  100. All exported functions are private.
  101.  
  102. Foundation::FWRunTyp
  103.  
  104. No functions are exported from the shared library.
  105.  
  106. Foundation::FWExcLib
  107.  
  108. No functions are exported from the shared library.
  109.  
  110. Foundation::FWMemory
  111.  
  112. All exported functions are private.
  113.  
  114. Foundation::FWStream
  115.  
  116. All exported functions are private.
  117. This subsystem defines six SOM classes: 
  118. FW_OSink
  119. FW_OBufferedSink
  120. FW_OMemorySink
  121. FW_OObjectRegistry
  122. FW_OBasicObjectRegistry
  123. FW_ORandomAccessSink
  124.  
  125. Foundation::FWString
  126.  
  127. This subsystem defines the following public functions: 
  128. FW_LocaleIsSingleByte
  129. FW_CharIsDoubleByte
  130.  
  131. This subsystem defines five SOM classes: 
  132. FW_OTextRunReader
  133. FW_OTextRunWriter
  134. FW_OMemoryRunReader
  135. FW_OMemoryRunWriter
  136. FW_OStringRunWriter
  137.  
  138. Foundation::FWRefCnt
  139.  
  140. This subsystem defines one SOM class:
  141. FW_ORefCount
  142.  
  143. OS::FWFiles
  144.  
  145. This subsystem defines four SOM classes:
  146. FW_OFile
  147. FW_OFileSink
  148. FW_OFileSpecification
  149. FW_ODirectorySpecification
  150.  
  151. OS::FWOSMisc
  152.  
  153. This subsystem defines the following public functions:
  154. FW_GetODFLibraryVersion
  155. FW_ChooseFileToOpen
  156. FW_ChooseFileToSave
  157.  
  158. OS::FWODMisc
  159.  
  160. All exported functions are private.
  161.  
  162. This subsystem defines one SOM class:
  163. FW_OStorageUnitSink
  164.  
  165. OS::FWResour
  166.  
  167. This subsystem defines four SOM classes:
  168. FW_OResourceFile
  169. FW_OResource
  170. FW_OResourceSink
  171.  
  172. OS::FWThread
  173.  
  174. This subsystem defines the following public functions:
  175. FW_Thread_NoteCreation
  176. FW_Thread_NoteTermination
  177. FW_Thread_NoteSwitch
  178.  
  179. OS::FWToolbx
  180.  
  181. This subsystem defines the following public functions:
  182. FW_MacGetMaxIntersectedDevice
  183. FW_MacZoomWindow
  184. FW_CenterRectOnScreen
  185. FW_GetMainScreenBounds
  186. FW_Beep
  187. FW_GetTickCount
  188. FW_PositionModalDialog
  189. FW_FitWindowToScreen
  190. FW_SetWindowSize
  191. FW_SetWindowPosition
  192. FW_GetWindowSize
  193. FW_GetWindowPosition
  194. FW_SetWindowTitle
  195. FW_GetWindowTitle
  196. FW_GetWindowBorderSize
  197. FW_ScreenToWindow
  198. FW_WindowToScreen
  199.  
  200. OS::FWGraphics
  201.  
  202. This subsystem defines the following public functions:
  203. FW_MacRGBToColor
  204. FW_MacColorToRGB
  205. FW_GetPaletteSize
  206. FW_SetPaletteEntries
  207. FW_GetPaletteEntries
  208. FW_DestroyPalette
  209. FW_NewRegion
  210. FW_CreateRectRegion
  211. FW_CreateOvalRegion
  212. FW_CreateRoundRectRegion
  213. FW_CreateArcRegion
  214. FW_CreatePolygonRegion
  215. FW_CreateLineRegion
  216. FW_DisposeRegion
  217. FW_CopyRegion
  218. FW_CopyRegionTo
  219. FW_GetRegionBoundingBox
  220. FW_OutlineRegion
  221. FW_EmptyRegion
  222. FW_InsetRegion
  223. FW_MapRegion
  224. FW_OffsetRegion
  225. FW_PointInRegion
  226. FW_RectInRegion
  227. FW_IsEmptyRegion
  228. FW_WriteRegion
  229. FW_ReadRegion
  230. FW_UnionRegion
  231. FW_XorRegion
  232. FW_SubtractRegion
  233. FW_IntersectRegion
  234. FW_RegionCode
  235. FW_PtInOval
  236. FW_PtInRoundRect
  237. FW_HitTestLine
  238. FW_HitTestPolygon
  239. FW_LogPoint
  240. FW_LogRect
  241. FW_LogShape
  242. FW_LogTransform
  243.  
  244. Framework::FWSemEvt
  245.  
  246. This subsystem defines one SOM class:
  247. FW_OSemanticInterface
  248.  
  249.  
  250. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  251. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.